package cn.school.thoughtworks.section1;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;

public class PracticeC {
    List<String> collectSameElements(List<String> collection1, Map<String,List<String>> collection2) {
        List<String>  collection4 = new ArrayList<String>();

        HashSet<String> hashSet = new HashSet<String>();

        for (List<String> s :  collection2.values()) {
            for (String s1 :  s) {
                    collection4.add(s1);
            }

        }
        for (String s :  collection1) {
            if(hashSet.add(s)==false){
                collection4.add(s);
            }
        }


        return  collection4;
    }
}
